<form class="form-horizontal" id="form-add-admin">

    <div class="form-group">
        <label for="role-selector" class="control-label col-xs-2">角色</label>
        <div class="col-xs-9">
            <select name="role" id="role-selector" class="form-control" required>
                {volist name="role_list" id="item"}
                <option value="{$item.id}">{$item.name}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">名称：</label>
        <div class="col-xs-9">
            <input type="text" class="form-control" placeholder="输入管理员名称" name="name" required>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">描述：</label>
        <div class="col-xs-9">
            <textarea rows="3" class="form-control" name="desc" placeholder="输入管理员描述信息"></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">账号：</label>
        <div class="col-xs-9">
            <input type="text" class="form-control" placeholder="输入登录账号" name="username" required>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-2">密码：</label>
        <div class="col-xs-9">
            <input type="password" class="form-control" placeholder="输入登录密码" name="password" required>
        </div>
    </div>

    <div class="form-group">
        <div class="col-xs-offset-2 col-xs-3">
            <button type="submit" class="btn btn-success">确认添加</button>
        </div>
    </div>
</form>

<!-- Select2 -->
<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script src="__PUBLIC__/vendors/jquery.validation/jquery.validate.min.js"></script>
<script src="__PUBLIC__/vendors/jquery.validation/additional-methods.js"></script>
<script src="__PUBLIC__/vendors/jquery.validation/messages_zh.min.js"></script>
<script type="application/javascript">
    $(function () {
        $("#role-selector").select2({
            placeholder: "选择管理员的角色",
            allowClear: true,
            width: "100%"
        });

        $("#form-add-admin").validate({
            messages:
                {
                    role: "必须选择一个角色",
                    name: "必须填写管理员的名称",
                    username: "必须填写登录账号",
                    password: "必须填写登录密码"
                },
            submitHandler: function () {
                ajaxSubmit('form-add-admin', true);
            }
        })
    })
</script>